package qgs.zisu.javaconcurrency.javaconcurrency;

/**
 * @Author: 蔡翔
 * @Date: 2019/9/26 13:19
 * @Version 1.0
 */
public class Test2 {
    private volatile static int INIT_VALUE = 0;
    private final static int MAX_LIMIT = 50;
    public static Integer a = 0;
    public static void main(String[] args) throws Exception {



        new Thread(()->{
            while (INIT_VALUE ==1){
                try {
                    System.out.println(Thread.currentThread().getName()+"in while");
                    Thread.sleep(111);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println(a);
        },"ADDER-2").start();

        new Thread(()->{
            a = 1;
            INIT_VALUE = 1;
            System.out.println("push a into main memory");
        },"ADDER-1").start();
    }
}